/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pollobeta;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.net.Socket;
import java.util.ArrayList;
import javax.swing.JComponent;

/**
 *
 * @author arturo
 */
public class Paint extends JComponent{

    private ArrayList<Point> puntos = new ArrayList<Point>();
    private boolean borrar = false;
    private boolean miTurno;

    public Paint(Socket s){

        setPreferredSize(new Dimension(300, 500));
        setFocusable(true);
        requestFocus();




        addMouseMotionListener(new MouseAdapter() {

            @Override
            public void mouseDragged(MouseEvent e) {

                puntos.add(e.getPoint());
                repaint();

            }




        });


    addMouseListener(new MouseAdapter() {

            @Override
            public void mousePressed(MouseEvent e) {

                puntos.add(e.getPoint());
                repaint();


            }



        });

    }


    public Paint() {

        setPreferredSize(new Dimension(300, 500));
        setFocusable(true);
        requestFocus();
        



        addMouseMotionListener(new MouseAdapter() {

            @Override
            public void mouseDragged(MouseEvent e) {

                puntos.add(e.getPoint());
                repaint();

            }




        });


    addMouseListener(new MouseAdapter() {

            @Override
            public void mousePressed(MouseEvent e) {

                puntos.add(e.getPoint());
                repaint();


            }



        });
    }

    @Override
        public  void paint(Graphics g){

        if(!borrar){

                for (Point point : puntos) {

                    g.setColor(Color.blue);
                    g.fillOval(point.x, point.y, 10, 10);

               }
        }

        if(borrar){

            puntos.clear();
            borrar = false;

              }

    }

    public void borrar(){

        borrar = true;
        repaint();

    }

}

